package com.geektime.tdd.tdd;

import java.util.List;

public class BooleanOptionParser implements OptionParse {
    @Override
    public Object parse(List<String> argments, Option option) {
        //等价于 indexof  index = -1
        int index = argments.indexOf("-" + option.value());
        if(index+1 < argments.size() || !argments.get(index+1).startsWith("-")) throw new TooManyArgumentsException(option.value());
        return index != -1;
    }
}
